// Have include guard.
#ifndef ASYNCRESULTSTARTSTATE_H
#define ASYNCRESULTSTARTSTATE_H

// Include files.
#include <boost/smart_ptr/shared_ptr.hpp>
#include "StateDoneCode.hpp"
#include "State.hpp"
#include "AsyncResult.hpp"
#include "AsyncResultFinishState.hpp"

/**
 *  The AsyncResultStartState class is a state that generates a AsyncResult.
 *  
 *  This class is untested.
 */
template<typename Result>
class AsyncResultStartState :
	public State
{
	friend class AsyncResultFinishState<Result>;
	
	public:
		typedef AsyncResultFinishState<Result> FinishState;
		
		/**
		 *  Constructor for AsyncResultStartState.
		 */
		AsyncResultStartState() :
			m_asyncResult()
		{
		}
	protected:
		/**
		 *  Set the AsyncResult to be used by a corresponding
		 *  AsyncResultFinishState, and finish this state with
		 *  a success StateDoneCode.
		 * 
		 *  @param asyncResult The AsyncResult to set this AsyncResultStartState to.
		 */
		void SetAsyncResult(boost::shared_ptr<AsyncResult<Result> > asyncResult)
		{
			m_asyncResult = asyncResult;
			SetDoneCode(StateDoneCode::GetSuccessCode());
		}
	private:
		boost::shared_ptr<AsyncResult<Result> > m_asyncResult;
		
		boost::shared_ptr<AsyncResult<Result> > GetAsyncResult()
		{
			return m_asyncResult;
		}
};

#endif // #ifndef ASYNCRESULTSTARTSTATE_H 
